% This file makes a table based on func_wrapper_shortlong
% The idea in that file was to see if the gains from completing choice sets
% varied with whether teachers were on the short or long side of the market

clear all;
close all;
clc

cd  E:\ReplicateBuild\02_code\03_matlab

store_suffix='serialdict';

%%%
% restricted timing
%%%
base=['alloc_serialdict_',store_suffix,'.mat'];
basefilename=join(base);
folder='../../01_data/05_temp/model/';
savefile=fullfile(folder, basefilename);


basedata=open(savefile);

balanced_restr=basedata.balanced;



%%
% MATLAB script to produce a LaTeX table with dynamic data

% Specify the directory path where you want to save the .tex file
save_path = 'E:\ReplicateBuild\03_output\tables\';

% Complete file path with file name
file_name = [save_path 'serialdict.tex'];

% Open a file to write
fileID = fopen(file_name,'w');

% Check if the file was opened successfully
if fileID == -1
    error('File could not be opened, check if the path is correct and writable.');
end

%[va_disadv va_adv fracdisadv_matched fracdisadv_unmatched va_disadv_unmatch];
% Write the table header and begin the tabular environment
fprintf(fileID, '\\begin{tabular}{lcccccccc} \\hline \\noalign{\\smallskip} \\multicolumn{1}{l}{Description} & \\multicolumn{1}{l}{VA disadv.} & \\multicolumn{1}{l}{VA adv.} & \\multicolumn{1}{c}{Dis. share among matched} & \\multicolumn{1}{c}{Dis share among unmatched} & \\multicolumn{1}{c}{Share matched}  \\noalign{\\smallskip}  \\\\\\hline \\noalign{\\smallskip}  \n');
fprintf(fileID, 'Teacher most preferred  & %.3f & %.3f & %.3f & %.3f & %.3f   \\\\\n', balanced_restr(1,3:7));
fprintf(fileID, 'Serial dictatorship (VA Dis.) & %.3f & %.3f   \\\\\n', balanced_restr(1,1:2));

% End the tabular environment and close the table
fprintf(fileID, '\\noalign{\\smallskip}\\hline\\end{tabular}\n');

% Close the file
fclose(fileID);

% Notify the user
fprintf('LaTeX table saved to %s\n', file_name);

